package com.wky1.wang1.Controller;

import com.wky1.wang1.Request;
import com.wky1.wang1.pojo.Pagebean;
import com.wky1.wang1.service.StudentService;
import com.wky1.wang1.pojo.Student;

import jdk.internal.instrumentation.Logger;
import lombok.extern.slf4j.Slf4j;
import lombok.extern.slf4j.XSlf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Slf4j
@RequestMapping("/wky1")
@RestController
public class StudentController {

    @Autowired
    private StudentService studentService;


    //查询
    
     @GetMapping("/wky2")
    public Request Stulist(){
         List<Student> stulist= studentService.list();
        log.info("stulist");
             return Request.success(stulist);
         }


     //新增
@PostMapping("/wky33")
    public Request settte(@RequestBody Student student){
System.out.println(student);
        studentService.set(student);
         return Request.success();
    }

    //修改
@PutMapping("/update")
    public Request  update( @RequestBody Student student){
         studentService.update(student);
    System.out.println(student);
         return Request.success();
    }


    //批量删除
    @DeleteMapping("/delete/{ids}")
    public Request delete(@PathVariable List<Integer> ids){
         studentService.delete(ids);
         return Request.success();
    }

    //分页查询
    @GetMapping("/select")
    public Request selectall(@RequestParam(defaultValue = "1") Integer page,
                             @RequestParam(defaultValue = "10") Integer pageSize,
                             String name,String num,Integer age   ){
         Pagebean pagebean =studentService.selectall(page,pageSize,name,num,age);
         return Request.success(pagebean);
    }

}
